﻿using System;
using System.ServiceModel;

namespace CoreEx.ServiceModel
{
    /// <summary>
    /// Extends the <see cref="Type"/> class to provide functionality for 
    /// determining if a given type represents a service contract.    
    /// </summary>
    public static class TypeExtensions
    {
        /// <summary>
        /// Determines whether the <paramref name="type"/> represents a service contract.
        /// </summary>
        /// <param name="type">The target <see cref="Type"/></param>
        /// <returns>
        /// 	<c>true</c> if the type represents a service contract, otherwise <c>false</c>.
        /// </returns>
        public static bool IsServiceContract(this Type type)
        {
            return type.IsDefined(typeof(ServiceContractAttribute), true);
        }
    }
}